package cn.edu.zbu.servlet;

import cn.edu.zbu.cn.edu.zbu.dao.CarDao;
import cn.edu.zbu.cn.edu.zbu.dao.CarDaoImpl;
import cn.edu.zbu.pojo.Car;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "QueryServlet", value = "/QueryServlet")
public class QueryServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        CarDao dao=new CarDaoImpl();
        List<Car> cars=dao.findAll();
        request.getSession().setAttribute("cars",cars);
        response.sendRedirect(request.getContextPath()+"/list.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
